package com.mlnx.web.data.controller;


import com.mlnx.common.entity.Response;
import com.mlnx.common.entity.ResponseData;
import com.mlnx.common.form.PageForm;
import com.mlnx.external.push.service.TPushDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.shan.spring.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


@Api(value = "推送与设备关系接口",tags={"推送与设备关系接口"})
@RestController
@RequestMapping("push/device")
public class PushDeviceController extends BaseController {

    @Autowired
    private TPushDeviceService tPushDeviceService;


    @ApiOperation("删除推送与设备关系数据")
    @RequestMapping(value = "", method = {RequestMethod.DELETE})
    public Response deleteRelation( @RequestParam(value = "ids", required = true) List<Integer> ids) {
        tPushDeviceService.removeByIds(ids);
        return result();

    }

    @ApiOperation("分页获取所有关系数据")
    @GetMapping(value = "")
    public ResponseData listPage(@Valid PageForm pageForm,@RequestParam Integer id) {


        return result(tPushDeviceService.listPage(pageForm,id));
    }


    @ApiOperation("新增推送与设备关系")
    @RequestMapping(value = "", method = {RequestMethod.POST})
    public Response addRelation(@RequestParam(value = "ids", required = true) List<Integer> ids,@RequestParam Integer pushId) {
        tPushDeviceService.add(ids,pushId);
        return result();

    }
}
